package com.srwl.mytx.widget;

import android.content.Context;
import android.view.KeyboardShortcutGroup;
import android.view.Menu;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;

import com.amap.api.services.core.PoiItem;
import com.srwl.mytx.R;
import com.srwl.mytx.adapter.AddressSearchResultAdapter;
import com.srwl.mytx.adapter.BottomDialogAdapter;
import com.srwl.mytx.adapter.MapBottomTopicAdapter;
import com.srwl.mytx.domain.Topic;
import com.srwl.mytx.utils.Utils;

import java.util.List;

public class TopicDialog extends BottomSheetDialog {
    private List<Topic> dialogItems;
    RecyclerView rv_dialogItems;
    private MapBottomTopicAdapter topicAdapter;

    public TopicDialog(@NonNull Context context) {
        super(context);
    }

    public TopicDialog(@NonNull Context context, List<Topic> dialogItems) {
        super(context, R.style.BottomDialog_v1);
        this.dialogItems = dialogItems;
        init(context, dialogItems);
    }


    void init(@NonNull Context context, List<Topic> dialogItems) {
        setContentView(R.layout.address_search_dialog);

        rv_dialogItems = findViewById(R.id.rv_dialog);
        PagerSnapHelper pagerSnapHelper = new PagerSnapHelper() {
            @Override
            public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY) {
                int targetSnapPosition = super.findTargetSnapPosition(layoutManager, velocityX, velocityY);
//                if (listener != null) {
//                    listener.onPageChange(targetSnapPosition);
//                }
                return targetSnapPosition;
            }
        };
        pagerSnapHelper.attachToRecyclerView(rv_dialogItems);
        rv_dialogItems.setLayoutManager(new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false));
        topicAdapter = new MapBottomTopicAdapter(context, dialogItems);
        rv_dialogItems.setAdapter(topicAdapter);
    }

}
